package org.vineatoum.tracking;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Stack;

public class TrackInfo {

		private ITrackableElement trackedElement;
		private ArrayList<TrackInfo> fromElements = new ArrayList<TrackInfo>();
		private ArrayList<TrackInfo> childElements =  new ArrayList<TrackInfo>();
		
		private Stack<ITrackableElement> listedTracking = new Stack<ITrackableElement>();
		
		public Stack<ITrackableElement> getListedTracking() {
			return listedTracking;
		}
		public void setListedTracking(Stack<ITrackableElement> listedTracking) {
			this.listedTracking = listedTracking;
		}
		public ITrackableElement getTrackedElement() {
			return trackedElement;
		}
		public void setTrackedElement(ITrackableElement trackedElement) {
			this.trackedElement = trackedElement;
		}
		public ArrayList<TrackInfo> getFromElements() {
			return fromElements;
		}
		public void setFromElements(ArrayList<TrackInfo> fromElements) {
			this.fromElements = fromElements;
		}
		public ArrayList<TrackInfo> getChildElements() {
			return childElements;
		}
		public void setChildElements(ArrayList<TrackInfo> childElements) {
			this.childElements = childElements;
		}
		
		public boolean isFirstElement()
		{
			return this.fromElements.isEmpty();
		}
		public boolean isLastElement()
		{
			return this.childElements.isEmpty();
		}
		
		@Override
		public String toString()
		{
			Iterator<ITrackableElement> it = null;
			String returnString = "";
			returnString+="=== Tracking de "+this.trackedElement+" ===\n";
			it = this.listedTracking.iterator();
			while(it.hasNext())
			{
				ITrackableElement e = it.next();
				String me="";
				if(e==this.trackedElement)
				{
				 me = "It's me ! : ";
				}
				returnString+=me+e+"\n";
			}
			
			return returnString;
			
		}
		
		
		
}
